﻿
@page "/Bas/CodingRule/BatchEdit"
@using nERP.ViewModel.Bas.CodingRuleVMs
@using System.ComponentModel.DataAnnotations
@inherits BasePage

<ValidateForm @ref="vform" Model="@Model" OnValidSubmit="@Submit">
  <div style="margin-bottom:10px;"> @WtmBlazor.Localizer["Sys.BatchEditConfirm"]</div>
  <Row ItemsPerRow="ItemsPerRow.Two" RowType="RowType.Normal">
    <Select @bind-Value="@Model.LinkedVM.CodingListId" Items="AllCodingLists" Id="g41ba54dee35c4798b326cc0745d5e59f"/>
    <BootstrapInput @bind-Value="@Model.LinkedVM.Seq"/>
    <Select @bind-Value="@Model.LinkedVM.CodeRule" Id="gf7f9c72e7a714c17af326ccaaf3cd0cd"/>
    <BootstrapInput @bind-Value="@Model.LinkedVM.FixedValue"/>
    <Select @bind-Value="@Model.LinkedVM.FixedRule" Id="gbb46b2902401428c8cbb7e99eb47b38a"/>
    <BootstrapInput @bind-Value="@Model.LinkedVM.GlideLen"/>
    <BootstrapInput @bind-Value="@Model.LinkedVM.StartNumber"/>
    <BootstrapInput @bind-Value="@Model.LinkedVM.GlideStep"/>
    <BootstrapInput @bind-Value="@Model.LinkedVM.Glide"/>
  </Row>

  <div class="modal-footer table-modal-footer">
    <Button ButtonType="ButtonType.Submit" IsAsync="true" Text="@WtmBlazor.Localizer["Sys.Submit"]"/>
    <Button OnClick="OnClose" Text="@WtmBlazor.Localizer["Sys.Close"]"/>
  </div>

</ValidateForm>



@code {
    [Parameter]
    public string id { get; set; }
    [Parameter]
    public string[] ids { get; set; }
    private CodingRuleBatchVM Model = new CodingRuleBatchVM();
    private ValidateForm vform { get; set; }
    
    private async Task Submit(EditContext context)
    {
        Model.Ids = ids;
        await PostsForm(vform, "/api/Bas/CodingRule/BatchEdit", (s) => WtmBlazor.Localizer["Sys.BatchEditSuccess", s], method: HttpMethodEnum.POST);
    }
            

    public void OnClose()
    {
        CloseDialog();
    }
    
    private List<SelectedItem> AllCodingLists = new List<SelectedItem>();
    protected override async Task OnInitializedAsync()
    {
        
        
        AllCodingLists = await WtmBlazor.Api.CallItemsApi("/api/Bas/CodingRule/GetCodingLists");
        AllCodingLists.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"],Value = "" });

        await base.OnInitializedAsync();
    }
}
